﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KabiManagementWeb.Models;
namespace KabiManagementWeb.Controllers
{
    public class ExtraFeesCategoryController : Controller
    {
        KBManagementDataContext context = new KBManagementDataContext();
        //
        // GET: /ExtraFeesCategory/

        public ActionResult Index()
        {

            return View(context.CategoryExtraFees);
        }

        //
        // GET: /ExtraFeesCategory/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /ExtraFeesCategory/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /ExtraFeesCategory/Create

        [HttpPost]
        public ActionResult Create(CategoryExtraFee collection)
        {
            try
            {
                context.CategoryExtraFees.InsertOnSubmit(collection);
                context.SubmitChanges();
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /ExtraFeesCategory/Edit/5

        public ActionResult Edit(int id)
        {
            var cex = context.CategoryExtraFees.First(x => x.CEF_ID == id);
            return View(cex);
        }

        //
        // POST: /ExtraFeesCategory/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, CategoryExtraFee collection)
        {
            try
            {
                var cex = context.CategoryExtraFees.First(x => x.CEF_ID == id);
                cex.CEF_ID = collection.CEF_ID;
                cex.CEF_Name = collection.CEF_Name;
                context.SubmitChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /ExtraFeesCategory/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /ExtraFeesCategory/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
